/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-09-04 16:43:34
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-26 16:42:20
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\securcheck\CompanyLedger.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
import { TableIResponse } from '@/utils/Api'
import {
  GetPlanGroupType,
  PatrolPlanListType,
  ScheduleSendTaskDetailType,
  SendTasklistType,
  StateInfoList
} from '../linePatrol/type'
import { GroupListType, PutMoveTaskType, Template, UserLedgerListType } from './type'
export class SetSecurCheckApi {
  //查询民用（单位）户组列表
  async GetGroupList(params: any): Promise<TableIResponse<GroupListType[]>> {
    const result = (await service.get('/api/securcheck/securTask/list', {
      params
    })) as unknown as any
    return result
  }
  //查询所有民用（单位）户组列表
  async GetAllGroupList(params: any): Promise<any[]> {
    const result = (await service.get('/api/securcheck/securTask/listAll', {
      params
    })) as unknown as any
    return result.data
  }

  //删除表具台账列表
  async DeletGroupList(ids: string | undefined): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/securTask/${ids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增民用（单位）户组列表
  async AddGroupList(data: GroupListType): Promise<boolean> {
    const result = (await service.post('/api/securcheck/securTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改民用（单位）户组列表
  async EditGroupList(data: GroupListType): Promise<boolean> {
    const result = (await service.put('/api/securcheck/securTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //建立安检组获取详细信息
  async GetSecurTaskById(id: string | undefined): Promise<GroupListType> {
    const result = (await service.get(`/api/securcheck/securTask/${id}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //查询已选用户(单位)信息
  async GetGroupSelectList(params: any): Promise<TableIResponse<UserLedgerListType[]>> {
    const result = (await service.get('/api/securcheck/securTask/getSelectlist', {
      params
    })) as unknown as any
    return result
  }
  //查询未选用户(单位)信息
  async GetGroupSelectNotList(params: any): Promise<TableIResponse<UserLedgerListType[]>> {
    const result = (await service.get('/api/securcheck/securTask/getSelectNotlist', {
      params
    })) as unknown as any
    return result
  }
  //删除选择的用户(单位)信息
  async DeletSelData(params: any): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/securTask/delSelData`, {
      params
    })) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //民用(单位)户组任务移入移出

  async PutMoveTask(data: PutMoveTaskType): Promise<boolean> {
    const result = (await service.put(
      '/api/securcheck/securTask/putMoveTask',
      data
    )) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡检任务列表
  async GetSecurPlanList(params: any): Promise<TableIResponse<SendTasklistType[]>> {
    const result = (await service.get('/api/schedule/securTask/list', { params })) as unknown as any
    return result
  }
  //删除巡检计划
  async DeletSecurTask(uuid: string): Promise<boolean> {
    const result = (await service.delete(`/api/schedule/securTask/${uuid}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡检任务列表
  async GetStateInfoList(params: GetPlanGroupType): Promise<TableIResponse<StateInfoList[]>> {
    const result = (await service.get('/api/securcheck/securPlanList/securState', {
      params
    })) as unknown as any
    return result
  }
  //下发巡检计划详细信息
  async GetScheduleSecurTask(uuid: string | undefined): Promise<ScheduleSendTaskDetailType> {
    const result = (await service.get(`/api/schedule/securTask/${uuid}`)) as unknown as any
    const { code, data } = result as any
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //新增下发巡检计划
  async AddSecurTaskData(data): Promise<boolean> {
    const result = (await service.post('/api/schedule/securTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改下发巡检计划
  async EditSecurTaskData(data): Promise<boolean> {
    const result = (await service.put('/api/schedule/securTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改运行的状态
  async EditSecurTaskState(data: GetPlanGroupType): Promise<boolean> {
    const result = (await service.put(
      '/api/schedule/securTask/changeStatus',
      data
    )) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡检任务列表
  async SecurPlanList(params: PatrolPlanListType): Promise<TableIResponse<PatrolPlanListType[]>> {
    const result = (await service.get('/api/securcheck/securPlanList/list', {
      params
    })) as unknown as any
    return result
  }
  //转办
  async SecurPlanHandover(data): Promise<boolean> {
    const result = (await service.put(
      '/api/securcheck/securPlanList/handover',
      data
    )) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除安检任务
  async DeletSecurplan(uuid: string): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/securPlanList/${uuid}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询安检模版
  async SecurHdtemplate(uuid: string | undefined): Promise<Template> {
    const result = (await service.get(
      `/api/securcheck/tbSecurHdtemplate/securPlan/${uuid}`
    )) as unknown as any
    const { code, data } = result as any
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
}
export default new SetSecurCheckApi()
